<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <script src="../plugins/echarts/echarts.js"></script>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>会员分布统计
            <small>性别分布&年龄分布</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>会员分布统计</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart1" style="height:600px;"></div>
        </div>
    </div>
</div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart1 = echarts.init(document.getElementById('chart1'));

    // 使用刚指定的配置项和数据显示图表。
    //myChart.setOption(option);
    /**
     * 前端需要的数据模型
     *  {
         *      flag: true,
         *      message: "查询套餐预约数量统计成功！",
         *      data:{
         *           setmealNames:['入职无忧体检套餐', '粉红珍爱(女)升级TM12项筛查体检套餐']
         *           setmealCount:[
         *                 {value: 335, name: '入职无忧体检套餐'},
         *                  {value: 310, name: '粉红珍爱(女)升级TM12项筛查体检套餐'}
         *           ]
         *      }
         *  }
     *
     *
     */
    axios.get("http://localhost:82/report/getMemberMessage.do").then((res) => {
        console.log("res::" + res.data.data)
        myChart1.setOption({
            backgroundColor: '#f0f0f4',
            title: {
                text: "会员年龄分布(里)\n会员性别分布(外)",
                subtext: '',
                x: 'center'
            },
            tooltip: {
                trigger: 'item',
                formatter: '{a} <br/>{b}: {c} ({d}%)',
            },
            legend: [
                {
                    orient: 'horizontal',
                    x: '2%',
                    y: '12%',
                    align: 'left',
                    // 可以删除
                    data: ['0-18',
                        '19-30', '31-45', '45以上']
                },
                {
                    orient: 'horizontal',
                    x: '2%',
                    y: '4%',
                    align: 'left',
                    // 可以删除
                    data: ['男', '女', '未知'],

                }
            ],
            color: ["#f50", "#76e", "#298", "#357", "#999", "#003", "#f26"],
            series: [
                {
                    name: '年龄:(周岁)',
                    type: 'pie',
                    selectedMode: 'single',
                    radius: [0, '35%'],

                    label: {
                        position: 'inner'
                    },
                    labelLine: {
                        show: false
                    },
                    data: res.data.data.age
                },
                {
                    name: '性别',
                    type: 'pie',
                    radius: ['44%', '60%'],
                    label: {
                        formatter: '{a|{a}}{abg|}\n{hr|}\n  {b|{b}：}{c}  {per|{d}%}  ',
                        backgroundColor: '#eee',
                        borderColor: '#aaa',
                        borderWidth: 1,
                        borderRadius: 4,
                        shadowBlur: 1,
                        shadowOffsetX: 3,
                        shadowOffsetY: 1,
                        shadowColor: '#456',
                        padding: [0, 7],
                        rich: {
                            a: {
                                color: '#999',
                                lineHeight: 22,
                                align: 'center'
                            },
                            hr: {
                                borderColor: '#aaa',
                                width: '100%',
                                borderWidth: 0.5,
                                height: 0
                            },
                            b: {
                                fontSize: 16,
                                lineHeight: 33
                            },
                            per: {
                                color: '#eee',
                                backgroundColor: '#334455',
                                padding: [2, 4],
                                borderRadius: 2
                            }
                        }
                    },
                    data: res.data.data.sex
                }
            ]
        });
    });
</script>
</html>
